package com.example.demo.Service;

import com.example.demo.Entity.Message;
import com.example.demo.Entity.Result;
import com.example.demo.Mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class MessageServiceImp implements MessageService{

    @Autowired
    private MessageMapper messageMapper;

    @Override
    public void Insert(Message message) {
        messageMapper.insert(message);
    }

    @Override
    public void Delete(Integer id) {

            messageMapper.deleteById(id);


    }

    @Override
    public void Update(Message message) {
         messageMapper.updateById(message);
    }

    @Override
    public List<Message> Search(Integer receiveId) {
   return messageMapper.selectByResponseId(receiveId);
    }

    @Override
    public Message Get(Integer id) {
        return messageMapper.selectById(id);
    }

    @Override
    public void deleteMessage(Integer sendId, Integer receiveId) {
        messageMapper.deleteMessage(sendId, receiveId);
    }

    @Override
    public List<Message> SearchDialogue(Integer sendId,Integer receiveId){
        return messageMapper.selectByDialogue(sendId,receiveId);
    }
@Override
    public void deleteById(Integer Id){
        messageMapper.deleteById(Id);
}

}
